import { AppDataSource } from './data.source'
import { User } from './entity/User'
import { Profile } from './entity/Profile'

// OneToOne
AppDataSource.initialize().then(async () => {
    const newUser = new User();
    const date_ = +new Date();
    newUser.firstName = 'first' + date_
    newUser.lastName = 'last' + date_
    newUser.age = 18
    newUser.email = date_ + '@qq.com'
    newUser.isActive = date_ % 2 === 0
    await AppDataSource.manager.save(newUser)

    const newProfile = new Profile();
    newProfile.bio = '世界很美好感谢有你.__1的个人介绍'
    // newUser.profile = newProfile;
    newProfile.user = newUser;
    await AppDataSource.manager.save(newProfile)
})